{extend name="common/__base" /}
{block name="body"}

<form class="layui-form" action="" onsubmit="return false;" method="post">
    <input type="hidden" name="id" value="{$data.id}">
    <!-- 用户名 -->
    <div class="layui-form-item">
        <label class="layui-form-label"><i class="domino font-red">*&nbsp;</i>用户名：</label>
        <div class="layui-input-inline">
            <input type="text" name="username" value="{$data.username}" required="" lay-filter="required" placeholder="请输入用户名" class="layui-input">
        </div>
    </div>
    <!-- 密码 -->
    <div class="layui-form-item">
        <label class="layui-form-label"><i class="domino font-red">*&nbsp;</i>密码：</label>
        <div class="layui-input-inline">
            <input type="text" name="password" value="" placeholder="请输入密码" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">留空表示不修改密码</div>
    </div>
    <!-- 真实姓名 -->
    <div class="layui-form-item">
        <label class="layui-form-label">真实姓名：</label>
        <div class="layui-input-inline">
            <input type="text" name="realname" value="{$data.realname}" placeholder="请输入真实姓名" class="layui-input">
        </div>
    </div>
    <!-- 手机号 -->
    <div class="layui-form-item">
        <label class="layui-form-label">手机号：</label>
        <div class="layui-input-inline">
            <input type="text" name="phone" value="{$data.phone}" placeholder="请输入手机号" class="layui-input">
        </div>
    </div>
    <!-- qq -->
    <div class="layui-form-item">
        <label class="layui-form-label">qq：</label>
        <div class="layui-input-inline">
            <input type="text" name="qq" value="{$data.qq}" placeholder="请输入qq" class="layui-input">
        </div>
    </div>
    <!-- 状态 -->
    <div class="layui-form-item">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-block">
            <input type="checkbox" {if condition="$data.status eq 1"} checked="" {/if} name="status" lay-skin="switch" lay-text="正常|禁用">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="formSubmit">立即提交</button>
        </div>
    </div>
</form>
{/block}
{block name="js"}
<script type="text/javascript">
        var form = layui.form;
        var layer = layui.layer;
        form.render();

        form.on('submit(formSubmit)', function (data) {
            ajaxRequest('{:url("edit")}', data.field)
                .then(function(ret){
                    if (ret.code == 1) {
                        showMsg(ret.msg,{icon:1});
                        setTimeout(function(){
                            closeWindow();
                        },1000);
                    } else {
                        showMsg(ret.msg,{icon:2});
                        return false;
                    }
                })
                .catch(function(err){
                    console.log(JSON.stringify(err));
                });
        });
</script>
{/block}
